<template>
  <div class="bg">
    <!-- 时间搜索框 -->
    <!-- <searchTime
      @searchvalue="userSearch"
      :options="options"
      :selectBoolen="false"
      :selectTime="true"
    />-->

    <!-- 表格展示 -->
    <el-card class="card">
      <div slot="header">
        <el-row type="flex" justify="end">
          <el-col :span="2">
            <el-button type="primary" size="small" @click="newmenu">新建菜单</el-button>
          </el-col>
        </el-row>
      </div>
      <!-- 表格展示 -->
      <el-table
        :data="tableData"
        style="width: 100%;margin-bottom: 20px;"
        row-key="menuId"
        border
        :tree-props="{children: 'childMenuList'}"
      >
        <el-table-column prop="menuName" label="菜单名"></el-table-column>
        <el-table-column prop="menuUrl" label="地址"></el-table-column>
        <el-table-column fixed="right" label="操作" width="200">
          <template slot-scope="scope">
            <el-button type="primary" size="small" @click="lookmenu(scope.row)">查看/编辑</el-button>
            <el-button type="danger" size="small" @click="menuDelet(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        background
        layout="total,  prev, pager, next, jumper"
        :total="total"
        :current-page="current"
        style="margin-top:24px"
        @current-change="currentpange"
      ></el-pagination>
    </el-card>

    <!-- 弹窗 -->
  </div>
</template>

<script>
export default {
  data() {
    return {
      value: "",
      value1: "",
      downloadLoading: false,
      tableData: [], //获取菜单列表
      total: 0,
      current: 1
    };
  },
  mounted() {
    this.allmenulist();
    // console.log("sdfjkasdfhjk", this.$http.article.roleList());
  },
  methods: {
    // // 获取角色列表数据
    allmenulist() {
      let params = {
        size: 10,
        current: this.current
      };
      this.$http.article.allmenulist(params).then(res => {
        console.log("所有菜单列表", res);
        this.tableData = res.result.records;
        this.total = res.result.total;
      });
    },

    // 分页操作
    currentpange(val) {
      this.current = val;
      this.allmenulist();
    },

    // 新增菜单列表
    newmenu() {
      console.log("新增菜单列表", "newmenu");
      this.$router.push("/home/addmenulist");
    },
    // 查看修改编辑
    lookmenu(val) {
      console.log(val);
      this.$router.push({
        path: "/home/addmenulist",
        query: { menuId: val.menuId }
      });
    },
    // 删除角色列表
    menuDelet(val) {
      console.log("删除", val);
      this.$http.article.menulistdelete({ yjMenuId: val.menuId }).then(res => {
        if (res.code == 200) this.$message.success("删除成功");
        this.allmenulist();
        console.log("删除角色列表", res);
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.merchantData {
  display: flex;
  align-items: center;
  padding-top: 14px;
  .addmerchant {
    color: #409eff;
    font-size: 18px;
    font-family: Microsoft YaHei;
    font-weight: 400;
  }
  .merchantNum {
    color: #f23a3a;
    font-size: 18px;
    font-family: Microsoft YaHei;
    font-weight: 800;
  }
}

.clearfix {
  padding-bottom: 20px;
}
.bg {
  width: 100%;
  height: 100%;
  background-color: #f4f7fd;
  // overflow: hidden;
}

.card {
  width: 98%;
  margin: 0 auto;
  margin-top: 10px;
}
</style>